package cn.liuhuan1.service;

import cn.liuhuan1.redisImp.RedisImp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

/**
 * @Auther: liuhuan
 * @Date: 2021/4/21 - 04 - 21 - 21:17
 * @Description:
 * @version: 1.0
 */
@Service
public class RedisService implements RedisImp {

    @Autowired
    private RedisTemplate<String,String> redisTemplate;
    @Override
    public void setValueDate(String key, String value, Long time) {
        redisTemplate.opsForValue().set(key,value,time, TimeUnit.SECONDS);
    }

    @Override
    public String getValue(String key) {
        String value = redisTemplate.opsForValue().get(key);
        return value;
    }
}
